home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / -archivi / -recent1 / nsm_invert.lha / invert / invert.c < prev    next >
C/C++ Source or Header  |  1999-02-23  |  1KB  |  73 lines

  1. /*
  2.     Inverts the notes in the range. If no
  3.     range is specified, the current
  4.     track will be inverted.
  5.  
  6.     Made by Kjetil S. Matheussen 22.2.99.
  7.  
  8.     Recommended shortcut: Left Amiga + i
  9.  
  10.     e-mail: kjetilma@ifi.uio.no
  11.  
  12.     Address:
  13.     Kjetil S. Matheussen
  14.     5423 Sogn Studentby
  15.     0858 Oslo
  16.     Norway
  17. */
  18.  
  19. #include "/nsm.h"
  20. #define TRUE 1
  21. #define FALSE 0
  22.  
  23. void main(){
  24.     OCTABASE ob;
  25.     BLOCKBASE bb;
  26.  
  27.     UWORD starttrack,endtrack;
  28.     UWORD    startline,endline;
  29.    UWORD current,post,last;
  30.  
  31.     UWORD track,line;
  32.  
  33.     int first;
  34.  
  35.  
  36.     if((ob=getoctabase())==0) goto exit;            /* Allways include this line first in
  37.                                                                     your plug-ins. */
  38.     bb=getcurrblockbase(ob);
  39.  
  40.     if(isranged(ob)){
  41.         starttrack=getrangestarttrack(ob);
  42.         endtrack=getrangeendtrack(ob);
  43.         startline=getrangestartline(ob);
  44.         endline=getrangeendline(ob);
  45.     }else{
  46.         starttrack=getcurrtrack(ob);
  47.         endtrack=starttrack;
  48.         startline=0;
  49.         endline=getnumlines(bb)-1;
  50.     }
  51.  
  52.     for(track=starttrack;track<=endtrack;track++){
  53.         first=TRUE;
  54.         for(line=startline;line<=endline;line++){
  55.             current=getnote(bb,track,line);
  56.             if(current){
  57.                 if(!first){
  58.                     last=last+post-current;
  59.                     setnote(bb,track,line,last);
  60.                 }else{
  61.                     last=current;
  62.                     first=FALSE;
  63.                 }
  64.                 post=current;
  65.             }
  66.         }
  67.     }
  68.  
  69.     updateeditor(ob);
  70.  
  71. exit:
  72. }
  73.